package org.hank.compose_yyzs.db.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import org.hank.compose_yyzs.db.converters.FileTypeConverter
import kotlinx.coroutines.flow.Flow
import org.hank.compose_yyzs.bean.UnUploadInfo

/**
 *@auth: Hank
 *邮箱: cs16xiaoc1@163.com
 *创建时间: 2023/4/8 15:52
 *描述:
 */
@Dao
@TypeConverters(FileTypeConverter::class)
interface FileDao {
    @get:Query("select * from UnUploadInfo")
    val filesList: Flow<MutableList<UnUploadInfo>>?

    @Query("select * from UnUploadInfo where projectName = :projectName and subName = :subName")
    fun getUnUploadInfoByName(projectName:String,subName:String): UnUploadInfo?

    @Insert
    suspend fun insert(vararg uploadInfo: UnUploadInfo):LongArray

    @Query("SELECT COUNT(*) FROM UnUploadInfo")
    fun getUnUploadCount(): LiveData<Int>

    @Delete
    suspend fun del(uploadInfo: UnUploadInfo):Int

    @Update
    suspend fun edit(uploadInfo: UnUploadInfo):Int

    @Query("delete from UnUploadInfo")
    suspend fun delAll(): Int
}